package com.jn.exam.paperConsumer.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.jn.exam.R;
import com.jn.exam.paperConsumer.entity.PaperQuestionAnswer;
import com.jn.exam.paperConsumer.service.ExamService;
import com.jn.exam.paperConsumer.service.PaperQuestionAnswerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 江南大学1033190417
 * @date 2022/3/11 17:29
 */
@Api(description = "阅卷相关")
@RestController
@RequestMapping("/paperConsumer/mark")
public class MarkController {

    @Autowired
    private PaperQuestionAnswerService paperQuestionAnswerService;


    @ApiOperation("批阅一道试题")
    @PostMapping("markQuestion")
    public R markQuestion(String paperQuestionId, String studentId, Float score) {
        PaperQuestionAnswer paperQuestionAnswer=new PaperQuestionAnswer();
        paperQuestionAnswer.setPaperQuestionId(paperQuestionId).setStudentId(studentId).setScore(score).setIsMarked(true);
        boolean isOK = paperQuestionAnswerService.saveOrUpdateAnswer(paperQuestionAnswer);
        if (isOK){
            return R.ok().message("批阅成功");
        }
        return R.error().message("批阅失败");
    }

}
